﻿using System.Collections;
using System.Collections.Generic;

namespace Castle.MonoRail.ExtensionMethods.Helpers {
	public static class IDictionaryExtensions {
		public static void Add(this IDictionary self, DictionaryEntry e) {
			self.Add(e.Key, e.Value);
		}

		public static void Add(this IDictionary self, IEnumerable<DictionaryEntry> e) {
			foreach (var d in e) {
				self.Add(d);
			}
		}

		public static IEnumerable<KeyValuePair<T, R>> AsStrongDictionary<T, R>(this IDictionary d) {
			foreach (DictionaryEntry de in d) {
				yield return new KeyValuePair<T, R>((T)de.Key, (R)de.Value);
			}
		}
	}
}